package com.anzhen;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * Created by anzhen on 2017-5-9.
 */
public class CodeGenerator {

	public static void main(String[] args) throws IOException {
		List<String> strings = FileUtils.readLines(new File("doc_file"), "UTF8");
		String template = "\t /**\n" +
				"\t * doc\n" +
				"\t */\n" +
				"\tprivate type name;";
		for (String string : strings) {
			String result = null;
			String[] split = string.split(",");
			if (split[2].contains("STRING")) {
				result = template.replace("doc", split[1]).replace("type", "String").replace("name", split[0]);
			} else if (split[2].contains("DOUBLE")) {
				result = template.replace("doc", split[1]).replace("type", "BigDecimal").replace("name", split[0]);
			} else {
				System.out.println(Arrays.toString(split));
			}
			System.out.println(result);

		}
	}
}
